import { Toast } from "antd-mobile";
import { testCenterService } from "@/store/actions/TestCenterService";
import { getApiParms } from "./configImpl";

/**
 * 短信数据
 */
export const SMS_DATA = [];


/**
 * 获取短信数据
 */
export const getSmsCache = async () => {
    if (SMS_DATA.length === 0) {
        // 调用接口获取数据
        try {
            const parms = getApiParms("sms");
            const { success, message, data } = await testCenterService.getResultList(parms);
            if (success) {
                SMS_DATA.push(...data);
            } else {
                SMS_DATA.length = 0;
                Toast.show(message);
            }
        } catch (error) {
            SMS_DATA.length = 0;
            console.error("获取短信数据出错:", error);
        }
    }
    return SMS_DATA;
};


